package cn.yiyuan.base.untli;

import lombok.Data;

/**
 * @user m
 * @project system_boog
 * @date 2023-10-09
 * @package cn.yiyuan.base.untli
 */

@Data
public class AjaxResult {
    private Boolean success = true;
    private String msg ="操作成功";
    private Object data;

//    返回一个新的Ajax对象 用于表示AJAX操作是否成功。如果操作成功，它的值为true；否则，它的值为false。 success=成功
    public static AjaxResult success(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success=true;
        ajaxResult.msg="操作成功";
        return ajaxResult;
    }

    //方法重载
    //    返回一个新的Ajax对象
    public static AjaxResult success(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.data= data;
        ajaxResult.success=true;
        ajaxResult.msg="操作成功";
        return ajaxResult;
    }

    public static AjaxResult success(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success=true;
        ajaxResult.msg=msg;
        return ajaxResult;
    }

//    错误
public static AjaxResult error(String msg){
    AjaxResult ajaxResult = new AjaxResult();
    ajaxResult.success=false;
    ajaxResult.msg=msg;
    return ajaxResult;
}

    public static AjaxResult error(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success=false;
        ajaxResult.msg="无参错误请求";
        return ajaxResult;
    }


}
